<template>
    <div class="flexBox">
        <div class="TransparentCard rdzx">
            <div class="topCardFlex">
                <div class="topCardFlex_title">热点咨询</div>
                <div class="topCardFlex_gd" @click="jrxwJumpfun">更多>></div>
            </div>
            <div class="jrCardlistBox">
                <div class="jrCardfor" v-for="item in jrqueryNewsListData" :key="item.id" @click="jrxwDetails(item.id)" >
                    <div class="jrCardfor_text">{{ item.title }}</div>
                    <div class="jrCardfor_data">{{ item.create_time }}</div>
                </div>
            </div>
        </div>
    </div>
    <!-- <div class="jrfwBox">
        <BlackTitleSlot title="金融服务" :showMore="true">
            <template #nr>
                <div class="jrfwFlex">
                    <div class="jrfwFor" v-for="(item,index) in jrfwList" :key="index">
                        <img v-if="index % 2 == 0" class="jrfwbjImg" src="@/assets/jrxx/jrfwbjlan.png" alt="">
                        <img v-if="index % 2 != 0" class="jrfwbjImg" src="@/assets/jrxx/jrfwbjhuang.png" alt="">
                        <div class="jrfwnr">
                            <img class="jrfwnr_img" :src="item.src" alt="">
                            <div class="jrfwnr_title">{{ item.title }}</div>
                            <div class="jrfwnr_text">{{ item.text }}</div>
                            <div class="jrfwnr_button">立即查看</div>
                        </div>
                    </div>
                </div>
            </template>
</BlackTitleSlot>
</div> -->
    <div class="jrcpBox">
        <BlackTitleSlot title="金融产品" :showMore="true" @more-click="jrcpListFun()">
            <template #nr>
                <div class="jrcpnr">
                    <div class="jrcpnrFor" v-for="item in lcFinancialProductInfosDWLoadData" :key="item.id">
                        <div class="jrcpnrFor_img">
                            <img style="width: 100%;height: 100%;" :src="store.imgfengMian + item.fengmian" alt="">
                        </div>
                        <div class="jrcpFor_nrFlex">
                            <div class="jrcpFor_nrTitle">{{ item.name }}</div>
                            <div class="jrcpFor_nrbfb">{{ item.base_rate_min }}-{{ item.base_rate_max }}%</div>
                            <div class="jrcpFor_nrbfbms">参考利率范围</div>
                            <div class="jrcpFor_nrText">贷款金额：{{ item.loan_limit }}万</div>
                            <div class="jrcpFor_nrText">贷款期限：{{ item.loan_term }}个月</div>
                            <div class="jrcpFor_nButton" @click="jrcpDetailsfun(item.id)">查看详情</div>
                        </div>
                    </div>
                </div>
            </template>
        </BlackTitleSlot>
    </div>
    <div class="jrjgBox">
        <BlackTitleSlot title="金融机构">
            <template #nr>
                <div class="jrjgFlex">
                    <img class="jrjgFor" v-for="item in lcFinancialProductInfosDWLoadData" :key="item" :src="store.imgfengMian + item.fengmian" alt="">
                </div>
            </template>
        </BlackTitleSlot>
    </div>
</template>
<script setup>
import BlackTitleSlot from '@/components/general/BlackTitleSlot.vue';
import { lcFinancialProductInfosDWLoad, queryNewsList } from '@/api/api.js'
import { ref, onMounted } from 'vue';
import { useStore } from '@/store/store';
const store = useStore();
import { useRouter } from 'vue-router';
const router = useRouter();
const jrfwList = ref([
    {
        src: new URL('@/assets/jrxx/ed.png', import.meta.url).href,
        title: 'e贷',
        text: '由省市（县）风险补偿基金提供的增信产品'
    },
    {
        src: new URL('@/assets/jrxx/ysd.png', import.meta.url).href,
        title: '银税贷',
        text: '由省市（县）风险补偿基金提供的增信产品'
    },
    {
        src: new URL('@/assets/jrxx/zfdk.png', import.meta.url).href,
        title: '住房贷款',
        text: '由省市（县）风险补偿基金提供的增信产品'
    },
    {
        src: new URL('@/assets/jrxx/xyd.png', import.meta.url).href,
        title: '信用贷',
        text: '由省市（县）风险补偿基金提供的增信产品'
    },
    {
        src: new URL('@/assets/jrxx/kd.png', import.meta.url).href,
        title: '快贷',
        text: '由省市（县）风险补偿基金提供的增信产品'
    },
    {
        src: new URL('@/assets/jrxx/snd.png', import.meta.url).href,
        title: '涉农款',
        text: '由省市（县）风险补偿基金提供的增信产品'
    }
])
onMounted(() => {
    queryNewsListfun()
    lcFinancialProductInfosDWLoadfun()
})
// 金融信息数据获取
const jrqueryNewsListData = ref([])
const queryNewsListfun = async () => {
    const res = await queryNewsList({
        page: 1,
        limit: 5,
        new_type:'009'
    })
    jrqueryNewsListData.value = res.data
}
// 产品列表
const lcFinancialProductInfosDWLoadData = ref([])
const lcFinancialProductInfosDWLoadfun = async () => {
    const res = await lcFinancialProductInfosDWLoad({
        pageNum: 1,
        pageSize: 8,
    })
    lcFinancialProductInfosDWLoadData.value = res.result
}
// 金融新闻跳转列表
const jrxwJumpfun = () => {
    router.push({
        path: '/newsList',
        query: { title: '金融信息' }
    });
}
// 列表跳转
const jrcpListFun = () => {
    router.push({
        path: '/financeList',
        query: {}
    });
}
// 详情跳转
const jrcpDetailsfun = (id) => {
    router.push({
        path: '/financeDetails',
        query: { id }
    });
}
// 热点咨询详情跳转
const jrxwDetails = (id) => {
    router.push({
        path: '/newsDetail',
        query: { id }
    });
}
</script>
<style scoped lang="scss">
.flexBox {
    display: flex;
    align-items: center;
}

.TransparentCard {
    background: rgb(255, 255, 255, 0.6);
    border-radius: 6px;
    // width: calc(50% - 10px); // 减去左右间距
    width: 100%;
    flex-shrink: 0;
    padding: 20px;
    height: 100%;
    min-height: 240px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.1); // 添加双层阴影增强立体感
}

.rdzx {
    margin-right: 20px; // 增加右侧间距
}

.tzgg {
    margin-left: 20px; // 增加左侧间距
}

.topCardFlex {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topCardFlex_title {
    font-weight: bold;
    font-size: 20px;
    color: #1F1F1F;
}

.topCardFlex_gd {
    font-size: 16px;
    color: #333333;
    cursor: pointer;
}

.jrCardlistBox {
    margin-top: 5px;

    .jrCardfor {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 0;
        cursor: pointer;

        &:hover {
            border-bottom: 1px dashed $green-color;

            .jrCardfor_text,
            .jrCardfor_data {
                color: $green-color !important; // 同时修改两个子元素的颜色
            }
        }

        .jrCardfor_text {
            font-weight: 300;
            font-size: 14px;
            color: #1F1F1F;
            width: 85%;
            white-space: nowrap; // 禁止换行
            overflow: hidden; // 隐藏溢出内容
            text-overflow: ellipsis; // 显示省略号
        }

        .jrCardfor_data {
            font-weight: 300;
            font-size: 14px;
            color: #454545;
        }
    }
}

.jrfwBox {
    margin-top: 40px;

    .jrfwFlex {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 20px; // 添加元素间距

        .jrfwFor {
            width: calc(33.333% - 13.333px); // 三列布局(6个
            height: 260px;
            background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(249, 249, 249, 0.8) 100%);
            border-radius: 8px;
            border: 1px solid #F1F1F1;
            position: relative;
            padding: 30px;
            padding-top: 20px;

            .jrfwbjImg {
                position: absolute;
                width: 100%;
                height: 100%;
                top: 0;
                left: 0;
            }

            .jrfwnr {
                height: 100%;
                position: relative;

                .jrfwnr_img {
                    width: 60px;
                    height: 60px;
                    margin-bottom: 10px;
                }

                .jrfwnr_title {
                    font-size: 22px;
                    color: #1F1F1F;
                    margin-bottom: 10px;
                }

                .jrfwnr_text {
                    font-size: 12px;
                    color: #1F1F1F;
                    margin-bottom: 20px;
                    display: -webkit-box;
                    -webkit-box-orient: vertical;
                    -webkit-line-clamp: 2;
                    line-clamp: 2;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    line-height: 1.5;
                }

                .jrfwnr_button {
                    width: 100px;
                    height: 30px;
                    font-size: 14px;
                    color: #0084FF;
                    border-radius: 20px;
                    border: 1px solid #0084FF;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    cursor: pointer;
                }
            }
        }
    }
}

.jrcpBox {
    margin-top: 40px;

    .jrcpnr {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 20px; // 添加元素间距

        .jrcpnrFor {
            width: calc(25% - 15px);
            background: #fff;

            .jrcpnrFor_img {
                width: 100%;
                height: auto;
                object-fit: contain;
                border-bottom: 2px solid #D9D9D9;
            }

            .jrcpFor_nrFlex {
                display: flex;
                flex-direction: column;
                align-items: center;
                padding: 20px 0;

                .jrcpFor_nrTitle {
                    font-size: 20px;
                    color: #1F1F1F;
                    margin-bottom: 12px;
                }

                .jrcpFor_nrbfb {
                    font-weight: bold;
                    font-size: 34px;
                    color: #EF1F1F;
                }

                .jrcpFor_nrbfbms {
                    font-size: 14px;
                    color: #1F1F1F;
                    margin-bottom: 20px;
                }

                .jrcpFor_nrText {
                    font-weight: 300;
                    font-size: 12px;
                    color: #1F1F1F;
                }

                .jrcpFor_nButton {
                    width: 100px;
                    height: 30px;
                    margin-top: 20px;
                    border-radius: 16px;
                    border: 1px solid #EF1F1F;
                    font-size: 14px;
                    color: #EF1F1F;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    cursor: pointer;
                }

            }
        }
    }
}

.jrjgBox {
    margin-top: 40px;

    .jrjgFlex {
        display: flex;
        gap: 20px;
        flex-wrap: wrap;

        .jrjgFor {
            width: calc(25% - 15px);
            flex-shrink: 0;
            height: auto;
            object-fit: contain;
            background: #FFFFFF;
            border-radius: 4px;
        }
    }
}
</style>